#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int haha[2000007];
int a[100005];
int main() {
	int n;
	cin>>n;
	int t, cnt=0;
	memset(haha, 0, sizeof(haha));
	for (int i=0; i<n; ++i) {
		scanf("%d", &t);
		cnt+=t;
		++haha[cnt];
		a[i]=cnt;
	}
	int maxn=cnt+32;
	long long res=0;
	for (int i=0; i<n; ++i) {
		t=sqrt(a[i]);
		if (t*t==a[i]) {
			++res;
		}
		res+=haha[a[i]]-1; haha[a[i]]--;
		for (int j=1; j<1009&&j*j+a[i]<maxn; ++j) {
			if (haha[j*j+a[i]]) res+=haha[j*j+a[i]];
		}
	}
	cout<<res<<endl;
	return 0;
} 
